package com.itheima.lianxi;

import java.util.Scanner;

/**
 * 需求：键盘录入一个字符串，使用程序实现在控制台遍历该字符串
 */
public class Demo2 {
    public static void main(String[] args) {
        //键盘录入字符串
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入字符串:");
        String str = sc.next();
        //将字符串变为字符数组
        char[] chars = str.toCharArray();
        //遍历字符数组,输出
        for (int i = 0; i < chars.length; i++) {
            //chars[i]
            System.out.println(chars[i]);
        }
    }
}
